using Unity.VisualScripting;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Load Config")]
    [UnitSurtitle("Success")]
    public sealed class LoadConfigSuccess : FrameworkEventUnit<LoadConfigSuccessEventArgs>
    {
        protected override int EventId => LoadConfigSuccessEventArgs.EventId;
        protected override string HookName => UGFHookNames.LoadConfigSuccess;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ConfigAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Duration
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            ConfigAssetName = ValueOutput<string>(nameof(ConfigAssetName));
            Duration = ValueOutput<float>(nameof(Duration));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, LoadConfigSuccessEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(ConfigAssetName, args.ConfigAssetName);
            flow.SetValue(Duration, args.Duration);
            flow.SetValue(UserData, args.UserData);
        }
    }
}